###
 # @Description: 
 # @Version: 2.0
 # @Autor: gang
 # @Date: 2020-09-17 17:30:23
 # @LastEditors: gang
 # @LastEditTime: 2020-10-22 14:16:53
 # 0    0    24    *    *    /usr/bin/curl -X POST -H "flag:tm"  "http://tunemakers-skintest.ulcampaign.com/csv/outdata"  > /dev/null
### 
#!/bin/bash
#ftp地址
SFTP_ADDR=sftp://xxxx.unilever-china.com:22
#用户名
USER="xxxx"
#密码
PASSWORD="xxx"
#待上传文件根目录
LOCAL_CLIENT_DIR=/home/outcsv

PRODTCT_SEVER_DIR=/u_jfgj/DailyFiles
#待上传文件名

function uploadFile(){
    read -p "请输入你要传输的文件名：" file
    if [ "${file}" = "exit" ]
        then
        break
    fi
    if [ -e $1\/${file} ]
        then
            FILE=${file}
            lftp -u $3,$4 $5 <<EOF
cd $2/
lcd $1
put ${FILE}
by
EOF
    else
        echo "文件不存在"
        continue
    fi
}

while true
do
    uploadFile $LOCAL_CLIENT_DIR $PRODTCT_SEVER_DIR $USER $PASSWORD $SFTP_ADDR
done
echo "结束上传任务\n\r";
